<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            /* 开启绝对定位不会影响页面的元素 */
            position: absolute;
            width: 70px;
            height: 50px;
        }
    </style>
</head>
<body>
    <img src="./img/mousemove.gif" alt="">
    <script>
        var pic = document.querySelector('img');
        document.addEventListener('mousemove',function(e){
            var x = e.pageX;
            var y = e.pageY;
            pic.style.left = x -35 +'px';//-35是为了居中
            pic.style.top = y -25 +'px' ;
        })
        // 跟随事件：常用在鼠标移动到图片时，将图片放大
    </script>
</body>
</html>